package com.stone.framework.push.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.stone.framework.message.ReqMessage;
import com.stone.framework.message.ResMessage;
import com.stone.framework.message.push.MessageReqBody;
import com.stone.framework.push.service.MessageService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import reactor.core.publisher.Mono;

@Api(tags = "消息")
@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @ApiOperation(value = "推送", httpMethod = "POST")
    @PostMapping(value = "/push")
    Mono<ResMessage<Void>> push(@Valid @RequestBody ReqMessage<MessageReqBody> reqMessage) {
        messageService.push(reqMessage.getBody());
        return Mono.just(ResMessage.success());
    }

}
